<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>复制</title>
</head>
<style>

</style>
<body>
    <div>
      <div id="copybox" class="copybox">
        <div id="writing">
          <img id="pd_superUrl" src="" alt="" style="width: 70px;height: 70px;" >
          <div id="pd_subTitle"></div>
          <div>原价：[<span id='pd_goodsPrice'></span>]元，券后价：[<span id='pd_goodsCouponPrice'></span>]元</div>
          <div id="pd_couponUrl"></div>
          <div id="pd_itemId"></div>
          <div id="pd_writing"></div>
        </div>
        <div id="widget">
          <img id="canvasimg" src="" alt="">
        </div>
      </div>
      <button >复制</button>
    </div>
    <script src="clipboard.min.js"></script>
    <script>
      var copybox = document.getElementById('copybox');
      var pd_superUrl = document.getElementById('pd_superUrl');
      var pd_subTitle = document.getElementById('pd_subTitle');
      var pd_goodsPrice = document.getElementById('pd_goodsPrice');
      var pd_goodsCouponPrice = document.getElementById('pd_goodsCouponPrice');
      var pd_couponUrl = document.getElementById('pd_couponUrl');
      var pd_itemId = document.getElementById('pd_itemId');
      var pd_writing = document.getElementById('pd_writing');
      var writing = document.getElementById('writing');
      // 营销图制作
      var widget = document.getElementById('widget');
      var canvasimg = document.getElementById('canvasimg');
       var makeimg=""
      var row = {};
      var clipboard = new ClipboardJS(copybox,{
        target:function () {
            return document.querySelector('.copybox')
        }
      });
      //成功回调
      console.log(clipboard)
      clipboard.on('success', function(e) {
        console.info('复制成功');
        e.clearSelection();
      });
      //失败回调
      clipboard.on('error', function(e) {
        console.error('复制失败', e.action);
      });
      function dorow(){
        // console.log('传入row',row)
        widget.style.display="none"
        pd_superUrl.src=row.pd_superUrl
        pd_subTitle.innerText=row.pd_subTitle
        pd_goodsPrice.innerText=row.pd_goodsPrice
        pd_goodsCouponPrice.innerText=row.pd_goodsCouponPrice
        pd_couponUrl.innerText=row.pd_couponUrl
        pd_couponUrl.innerText='领券：'+row.pd_couponUrl
        pd_itemId.innerText='抢购：https://detail.tmall.com/item.htm?id='+row.pd_itemId
        pd_writing.innerText=row.pd_writing
        copybox.click()
      }
      function domakeimg(){
        writing.style.display='none'
        canvasimg.src=makeimg
        copybox.click()
      }
    </script>
</body>
</html>
